package cn.sdhuijin.healthexam.control;

import java.util.Properties;

import android.app.Activity;
import android.widget.TextView;

/**
 * TextView控件
 * 
 * 
 * @author sunping
 */
public class TextViewControl implements IControl {
	private Activity activity;
	private TextView textView;
	private String name;

	public TextViewControl(Activity activity, int textViewId, String name) {
		this.activity = activity;
		this.textView = (TextView) this.activity.findViewById(textViewId);
		if (this.textView == null) {
			throw new RuntimeException(name + " EditText dont exist!");
		}
		this.name = name;
	}

	@Override
	public void getValue(Properties prop) {
		String value = this.textView.getText().toString().trim();
		if (value != null) {
			prop.setProperty(this.name, value);
		} else {
			prop.setProperty(this.name, "");
		}

	}

	@Override
	public void setValue(Properties prop) {
		String value = prop.getProperty(this.name);
		if (value != null) {
			this.textView.setText(value);
		}
	}

}
